#include<iostream>
using namespace std;
#include<vector>
class Solution {
public:
    int numberOfAlternatingGroups(vector<int>& colors, int k) {
        int n = colors.size(), ans = 0, now = 1;
        for (int i = 0; i < k - 1; ++i)
            colors.push_back(colors[i]);
        for (int left = 0, right = 1; right < colors.size(); ++right) {
            if (colors[right] != colors[right - 1])
                ++now;
            if (right - left + 1 > k) {
                ++left;
                now -= colors[left] != colors[left - 1];
            }
            if (right - left + 1 == k)
                ans += now == k;
        }
        return ans;
    }
};
int main() {
    vector<int> col{0, 1, 0, 1, 0};
    Solution().numberOfAlternatingGroups(col, 3);
}